<template>
  <div>
    <!--用户登录表格-->
    <el-table :data="getloginData" border style="width: 100%">
      <el-table-column prop="username" label="用户名" width="180"></el-table-column>
      <el-table-column prop="lastLogin.loginTime" label="上次登陆时间" width="180"></el-table-column>
      <el-table-column prop="lastLogin.ip" label="上次登陆地址"></el-table-column>
      <el-table-column prop="nowLogin.loginTime" label="本次登陆时间" width="180"></el-table-column>
      <el-table-column prop="nowLogin.ip" label="本次登陆地址"></el-table-column>
    </el-table>
    <!--分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[1, 2, 5, 10]"
      :page-size="5"
      layout="total, sizes, prev, pager, next, jumper"
      :total="20"
    ></el-pagination>
  </div>
</template>
<script>
export default {
  data () {
    return {
      getloginData: [],
      getloginList: { page: '1', count: '5' },
      currentPage4: 1
    }
  },
  created () {
    this.getloginDataMeth()
  },
  methods: {
    // 获取登陆信息
    async getloginDataMeth () {
      const { data: res } = await this.$http.get('/getloginlog', {
        params: this.getloginList
      })
      if (res.status !== 200) {
        this.$message.error('错了哦，这是一条错误消息')
      }
      this.getloginData = res.data
    },
    // 点击当前页显示几条数据
    handleSizeChange (val) {
      this.getloginList.count = val
      this.getloginDataMeth()
    },
    // 点击显示第几页的数据
    handleCurrentChange (val) {
      this.getloginList.page = val
      this.getloginDataMeth()
    }
  }
}
</script>

<style lang="less" scoped>
.el-pagination {
  margin-top: 20px;
}
</style>
